From d4c079bdc594d1d9ef3c7f9c3707638570d764d8 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 16 May 2008 09:30:10 +0100 Subject: [PATCH] ioemu: serial save/load fix This patch fixes several bugs in serial.c (1) A typo in serial_save() where qemu_get_8s is called (should be qemu_put_8s) (2) No support provided in serial_load() for version_id == 1 (should unmarshal a 1 byte s->divider and should provide a default value for s->fcr) (3) Call serial_ioport_write() to initialize s->fcr. It is not sufficient to load its value; other hidden values (such as s->recv_fifo.itl) must be re-initialized. Signed-off-by: Ben Guthro Signed-off-by: Robert Phillips --- tools/ioemu/hw/serial.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/ioemu/hw/serial.c b/tools/ioemu/hw/serial.c index af6aa64ee3..c6758315a2 100644 --- a/tools/ioemu/hw/serial.c +++ b/tools/ioemu/hw/serial.c @@ -705,12 +705,13 @@ static void serial_save(QEMUFile *f, void *opaque) qemu_put_8s(f,&s->lsr); qemu_put_8s(f,&s->msr); qemu_put_8s(f,&s->scr); - qemu_get_8s(f,&s->fcr); + qemu_put_8s(f,&s->fcr); } static int serial_load(QEMUFile *f, void *opaque, int version_id) { SerialState *s = opaque; + uint8_t fcr = 0; if(version_id > 2) return -EINVAL; @@ -729,6 +730,11 @@ static int serial_load(QEMUFile *f, void *opaque, int version_id) qemu_get_8s(f,&s->scr); qemu_get_8s(f,&s->fcr); + if (version_id >= 2) + qemu_get_8s(f,&fcr); + + /* Initialize fcr via setter to perform essential side-effects */ + serial_ioport_write(s, 0x02, fcr); return 0; } -- 2.30.2